﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace G.Net.Oauth
{
    public class Oauth2HttpGet : HttpGet
    {
        public Oauth2HttpGet(string url)
            : base(url)
        {

        }

        protected override void AppendHeaders(System.Net.Http.Headers.HttpRequestHeaders headers)
        {
            base.AppendHeaders(headers);
            if (OAuth2AccessToken.CurrentToken == null)
                throw new Exception("OAuth2AccessToken未初始化");
            headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", OAuth2AccessToken.CurrentToken.AccessToken);
        }
    }
}
